/*
 * @Author:
 * @Date: 2025-07-15 16:19:27
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2025-07-29 10:27:43
 * @Description: file content
 */
import { defineConfig } from "vite";
import uni from "@dcloudio/vite-plugin-uni";
import AutoImport from "unplugin-auto-import/vite";
import { fileURLToPath, URL } from "node:url";

// https://vitejs.dev/config/
export default defineConfig(async () => {
  const UnoCss = await import("unocss/vite").then((i) => i.default);
  return {
    plugins: [
      uni(),
      // 配置 UnoCSS
      UnoCss(),
      // 处理自动导入
      AutoImport({
        imports: ["vue", "uni-app"], // 自动导入 Vue 和 UniApp 的 API
        dts: "src/types/auto-imports.d.ts", // 自动生成类型声明文件
        eslintrc: {
          enabled: false, // 生成 ESLint 配置文件
        },
      }),
    ],
    resolve: {
      alias: {
        "@": fileURLToPath(new URL("./src", import.meta.url)),
        "#": fileURLToPath(new URL("./types", import.meta.url)),
      },
    },
    // build: {
    //   rollupOptions: {
    //     external: ["lodash"],
    //   },
    // },
  };
});
